<cfsilent>
<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: home.cfm 977 2006-11-11 19:38:20Z mpwoodward $

Notes:
--->

<cfset entries = event.getArg("entries") />
<cfset startRow = event.getArg("startRow", 1) />
<cfset numToDisplay = 1000000 />

<cfif event.getName() EQ "searchEntries" OR event.isArgDefined("categoryId") OR event.isArgDefined("month")>
	<cfset numToDisplay = getProperty("numEntriesPerPage") />
</cfif>


<cfif startRow + numToDisplay - 1 GT entries.RecordCount>
	<cfset endRow = entries.RecordCount />
<cfelse>
	<cfset endRow = startRow + numToDisplay - 1 />
</cfif>

<cfparam name="displayPrevLink" type="boolean" default="false" />
<cfparam name="displayNextLink" type="boolean" default="false" />

<cfif startRow NEQ 1 AND numToDisplay NEQ 1000000>
	<cfset displayPrevLink = true />
</cfif>

<cfif (entries.RecordCount GT startRow + numToDisplay - 1) AND numToDisplay NEQ 1000000>
	<cfset displayNextLink = true />
</cfif>
</cfsilent>
<script type="text/javascript">
	function toggleMoreBody(linkDiv, contentDiv) {
		if (document.getElementById(linkDiv).style.display == "block") {
			document.getElementById(linkDiv).style.display = "none";
			document.getElementById(contentDiv).style.display = "block";
		} else {
			document.getElementById(linkDiv).style.display = "block";
			document.getElementById(contentDiv).style.display = "none";
		}
	}
</script>

<cfoutput>
	
<cfif event.getName() EQ "searchEntries">
	<h3>
		#getProperty("resourceBundleService").getResourceBundle().getResource("searchresultsfor")# 
		"#event.getArg("searchTerms")#" - #entries.RecordCount# 
		<cfif entries.RecordCount NEQ 1>
		#getProperty("resourceBundleService").getResourceBundle().getResource("results")#
		<cfelse>
		#getProperty("resourceBundleService").getResourceBundle().getResource("result")#
		</cfif>
		&nbsp;
		[<a href="index.cfm?#getProperty('eventParameter')#=showHome">#getProperty("resourceBundleService").getResourceBundle().getResource("clearsearchresults")#</a>]
	</h3>
</cfif>

<cfif event.isArgDefined("categoryId")>
	<h3>
		#getProperty("resourceBundleService").getResourceBundle().getResource("viewingcategory")#: #event.getArg("categoryName")#</strong>&nbsp;
		[<a href="index.cfm?#getProperty('eventParameter')#=showHome">#getProperty("resourceBundleService").getResourceBundle().getResource("clearcategoryselection")#</a>]
	</h3>
</cfif>

<cfif displayPrevLink OR displayNextLink>
	<p>(#getProperty("resourceBundleService").getResourceBundle().getResource("displayingentries")# 
		#startRow# - #endRow#)</p>
</cfif>

<cfif event.isArgDefined("message")>
	<p style="color:red;font-weight:bold;">#event.getArg("message")#</p>
</cfif>
</cfoutput>

<cfif entries.RecordCount GT 0>
	<cfoutput query="entries" startrow="#startRow#" maxrows="#numToDisplay#">
		<div class="post">
			<h2><a href="index.cfm?#getProperty('eventParameter')#=showEntry&entryId=#entry_id#">#title#</a></h2>

			<div class="entry">
				#getProperty("udfs").renderEntry(body)#
				
				<cfif more_body NEQ "">
					<div id="moreBodyLink#entry_id#" style="display:block;padding-bottom:10px;">
						<a href="javascript:toggleMoreBody('moreBodyLink#entry_id#', 'moreBody#entry_id#');">
							<em>#getProperty("resourceBundleService").getResourceBundle().getResource("more")#</em>
						</a>
					</div>
					
					<div id="moreBody#entry_id#" style="display:none;">
						#getProperty("udfs").renderEntry(more_body)#<br />
						<br />
						<a href="javascript:toggleMoreBody('moreBodyLink#entry_id#', 'moreBody#entry_id#');">
							<em>[#getProperty("resourceBundleService").getResourceBundle().getResource("hideextendedentry")#]</em>
						</a>
					</div>
				</cfif>
		
				<cfif photo NEQ "">
					<div align="center">
						<img src="#getProperty('blogUrl')#/uploads/photos/#URLEncodedFormat(GetFileFromPath(photo))#" />
					</div>
				</cfif>
			</div>			

			<div class="footer">

				<div class="postmetadata">
					#getProperty("resourceBundleService").getResourceBundle().getResource("posted")# 
					#getProperty("resourceBundleService").getLocaleUtils().i18nDateFormat(dt_posted, 3)# 
					@ #getProperty("resourceBundleService").getLocaleUtils().i18nTimeFormat(dt_posted, 3)# 
					in

					<cfif ListLen(category_names) GT 0>
						<cfloop index="i" from="1" to="#ListLen(category_names)#">
							<a href="index.cfm?#getProperty('eventParameter')#=showEntriesByCategory&categoryId=#ListGetAt(category_ids, i)#&categoryName=#URLEncodedFormat(listGetAt(category_names, i))#">
							#ListGetAt(category_names, i)#</a><cfif i LT ListLen(category_names)>, </cfif>
						</cfloop>
					<cfelse>
						(#getProperty("resourceBundleService").getResourceBundle().getResource("uncategorized")#)
					</cfif>
				</div>


					<cfif allow_comments AND getProperty("allowComments")>
							<a href="javascript:doPopup('index.cfm?#getProperty('eventParameter')#=showComments&entryId=#entry_id#', 600, 600, false);">
								<cfif comment_count EQ 1>
									#getProperty("resourceBundleService").getResourceBundle().getResource("comment")#
								<cfelse>
									#getProperty("resourceBundleService").getResourceBundle().getResource("comments")#
								</cfif>
								(#comment_count#) 
							</a>
							|
					</cfif>
					
					<cfif allow_trackbacks AND getProperty("allowTrackbacks")>
							<a href="javascript:doPopup('index.cfm?#getProperty('eventParameter')#=showTrackbacks&entryId=#entry_id#', 600, 600, false);">
								<cfif trackback_count EQ 1>
									#getProperty("resourceBundleService").getResourceBundle().getResource("trackback")#
								<cfelse>
									#getProperty("resourceBundleService").getResourceBundle().getResource("trackbacks")#
								</cfif>
								(#trackback_count#)
							</a>
							|
					</cfif>
					
					<cfif enclosure NEQ "">
							<a href="#getProperty('blogUrl')#/uploads/enclosures/#URLEncodedFormat(GetFileFromPath(enclosure))#">
								#getProperty("resourceBundleService").getResourceBundle().getResource("downloadenclosure")#
							</a>&nbsp;(#enclosure_mime_type# <cfif enclosure_size / 1000 LT 1000>#NumberFormat(enclosure_size / 1000, "999")# KB<cfelse>#NumberFormat(enclosure_size / 1000000, "999.99")# MB</cfif>)
							|
					</cfif>
					
					
					<cfif getProperty("allowSendToFriend")>
							<a href="index.cfm?#getProperty('eventParameter')#=showSendEntryToFriend&entryId=#entry_id#">
								#getProperty("resourceBundleService").getResourceBundle().getResource("send")#
							</a>
					</cfif>
				




			</div>
		</div>
	</cfoutput>
	
	<cfoutput>
		<cfif displayPrevLink OR displayNextLink>
		<table width="100%">
			<tr>
				<td align="left">
					<cfif displayPrevLink>
						<cfset prevStartRow = startRow - numToDisplay />
						<a href="index.cfm?#getProperty('eventParameter')#=#event.getName()#<cfif event.isArgDefined('categoryId')>&categoryId=#event.getArg('categoryId')#&categoryName=#event.getArg('categoryName')#</cfif><cfif event.isArgDefined('searchTerms')>&searchTerms=#arguments.event.getArg('searchTerms')#</cfif>&startRow=#prevStartRow#">
							&lt; #getProperty("resourceBundleService").getResourceBundle().getResource("previous")#
						</a>
					<cfelse>
						&nbsp;
					</cfif>
				</td>
				<td align="right">
					<cfif displayNextLink>
						<cfset nextStartRow = startRow + numToDisplay />
						<a href="index.cfm?#getProperty('eventParameter')#=#event.getName()#<cfif event.isArgDefined('categoryId')>&categoryId=#event.getArg('categoryId')#&categoryName=#event.getArg('categoryName')#</cfif><cfif event.isArgDefined('searchTerms')>&searchTerms=#arguments.event.getArg('searchTerms')#</cfif>&startRow=#nextStartRow#">
							#getProperty("resourceBundleService").getResourceBundle().getResource("next")# &gt;
						</a>
					<cfelse>
						&nbsp;
					</cfif>
				</td>
			</tr>
		</table>
		</cfif>
		</cfoutput>

	<cfelse>
	<div style="height:500px;">
		<cfoutput><p><em><strong>#getProperty("resourceBundleService").getResourceBundle().getResource("noentries")#</strong></em></p></cfoutput>
	</div>
</cfif>
